# -*- coding:utf-8 -*-
import json

import requests


def tranmain(keyword):
    html = requests.get(url='http://fanyi.youdao.com/translate?&doctype=json&type=AUTO&i=' + keyword + '')
    jsonarr = json.loads(html.content.decode('utf-8'))
    print(jsonarr)
    bean = jsonarr.get('translateResult')[0][0]
    return '['+bean.get('src') + ']的翻译结果为：\n' + bean.get('tgt')

if __name__ == '__main__':
    print(tranmain('测试'))